package com.example.administrator.printoutindemo;

import android.content.Context;


import com.example.administrator.printoutindemo.database.SQLiteDBService;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class OutStorageDetail implements Serializable{

	private String _out_storage_detail_Id;
	private String _material;
	private String _projectname;
	private String _op_uid;
	private String _receive_address;
	private String _receive_userName;
	private String _receive_userPhone;
	private String _jd;
	private String _wd;
	private String _fmmaterial;
	private String _remark;
	private String _ostatus;
	private String _nums;
	private String _unit;
	private String likuBuffer;

	public String getLikuBuffer() {
		return likuBuffer == null ? "" : likuBuffer;
	}

	public void setLikuBuffer(String likuBuffer) {
		this.likuBuffer = likuBuffer == null ? "" : likuBuffer;
	}

	private SQLiteDBService sqliteDBservice;

	public OutStorageDetail() {

	}

	public OutStorageDetail(Context context) {
		sqliteDBservice = new SQLiteDBService(context);
	}

	//转化为json对象
	public String ConvertToJson(OutStorageDetail model) {
		String jsonStr = "";
		JSONObject modelJsonObject = new JSONObject();
		try {
			modelJsonObject.put("out_storage_detail_Id", model.get_out_storage_detail_Id());
			modelJsonObject.put("material", model.get_material());
			modelJsonObject.put("projectname", model.get_projectname());
			modelJsonObject.put("op_uid", model.get_op_uid());
			modelJsonObject.put("receive_address", model.get_receive_address());
			modelJsonObject.put("receive_userPhone", model.get_receive_userPhone());
			modelJsonObject.put("jd", model.get_jd());
			modelJsonObject.put("wd", model.get_wd());
			modelJsonObject.put("fmmaterial", model.get_fmmaterial());
			modelJsonObject.put("remark", model.get_remark());
			modelJsonObject.put("unit", model.get_unit());
			modelJsonObject.put("nums", model.get_nums());

			jsonStr = modelJsonObject.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonStr;
	}

	// 将JSON对象转化为list
	public List<OutStorageDetail> getListFromJSON(String JsonStr) {
		List<OutStorageDetail> clist = new ArrayList<OutStorageDetail>();

		try {

			JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

			for (int i = 0; i < jay.length(); i++) {
				JSONObject temp = (JSONObject) jay.get(i);

				OutStorageDetail n = new OutStorageDetail();

				n.set_material(temp.getString("material"));
				n.set_op_uid(temp.getString("op_uid"));
				n.set_out_storage_detail_Id(temp.getString("out_storage_detail_Id"));
				n.set_projectname(temp.getString("projectname"));
				n.set_receive_address(temp.getString("receive_address"));
				n.set_receive_userName(temp.getString("receive_userName"));
				n.set_receive_userPhone(temp.getString("receive_userPhone"));
				n.set_jd(temp.getString("jd"));
				n.set_wd(temp.getString("wd"));
				n.set_fmmaterial(temp.getString("fmmaterial"));
				n.set_unit(temp.getString("unit"));
				n.set_nums(temp.getString("nums"));

				clist.add(n);

			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return clist;

	}

	public String get_out_storage_detail_Id() {
		return _out_storage_detail_Id;
	}
	public void set_out_storage_detail_Id(String _out_storage_detail_Id) {
		this._out_storage_detail_Id = _out_storage_detail_Id;
	}
	public String get_material() {
		return _material;
	}
	public void set_material(String _material) {
		this._material = _material;
	}
	public String get_op_uid() {
		return _op_uid;
	}
	public void set_op_uid(String _op_uid) {
		this._op_uid = _op_uid;
	}
	public String get_projectname() {
		return _projectname;
	}

	public void set_projectname(String _projectname) {
		this._projectname = _projectname;
	}

	public String get_receive_address() {
		return _receive_address;
	}

	public void set_receive_address(String _receive_address) {
		this._receive_address = _receive_address;
	}

	public String get_receive_userName() {
		return _receive_userName;
	}

	public void set_receive_userName(String _receive_userName) {
		this._receive_userName = _receive_userName;
	}

	public String get_receive_userPhone() {
		return _receive_userPhone;
	}

	public void set_receive_userPhone(String _receive_userPhone) {
		this._receive_userPhone = _receive_userPhone;
	}
	public String get_jd() {
		return _jd;
	}

	public void set_jd(String _jd) {
		this._jd = _jd;
	}

	public String get_wd() {
		return _wd;
	}

	public void set_wd(String _wd) {
		this._wd = _wd;
	}

	public String get_fmmaterial() {
		return _fmmaterial;
	}

	public void set_fmmaterial(String _fmmaterial) {
		this._fmmaterial = _fmmaterial;
	}
	public String get_remark() {
		return _remark;
	}

	public void set_remark(String _remark) {
		this._remark = _remark;
	}
	public String get_ostatus() {
		return _ostatus;
	}

	public void set_ostatus(String _ostatus) {
		this._ostatus = _ostatus;
	}
	public String get_nums() {
		return _nums;
	}

	public void set_nums(String _nums) {
		this._nums = _nums;
	}

	public String get_unit() {
		return _unit;
	}

	public void set_unit(String _unit) {
		this._unit = _unit;
	}


}